package arpc

import (
	"context"
	"log"

	"github.com/zeromicro/go-zero/core/logx"
)

type Logger logx.Logger

var (
	Debug  = GetLogger().Debug
	Debugf = GetLogger().Debugf
	Debugv = GetLogger().Debugv
	Debugw = GetLogger().Debugw
	Error  = GetLogger().Error
	Errorf = GetLogger().Errorf
	Errorv = GetLogger().Errorv
	Errorw = GetLogger().Errorw
	Info   = GetLogger().Info
	Infof  = GetLogger().Infof
	Infov  = GetLogger().Infov
	Infow  = GetLogger().Infow
	Slow   = GetLogger().Slow
	Slowf  = GetLogger().Slowf
	Slowv  = GetLogger().Slowv
	Sloww  = GetLogger().Sloww
)

func MustInitLog(conf *LogConf) {
	if err := logx.SetUp(*conf); err != nil {
		log.Fatalf("error: init log %v", err)
		return
	}
}

func CloseLogger() {
	logx.Close()
}

func GetLogger() Logger {
	return GetLoggerWithContext(context.Background())
}

func GetLoggerWithContext(ctx context.Context) Logger {
	return logx.WithContext(ctx)
}
